Skip to content

Conversation

@orhalimi
Copy link

Prevent awkwardness when the db will have more than 25 documents. Getting the last N documents while maintaining ASC order.

Prevent awkwardness when the db will have more than 25 documents. Getting the last N documents while maintaining ASC order.
@ralfs66
Copy link

ralfs66 commented Apr 30, 2023

ERROR in src/App.tsx:92:65
TS2339: Property 'limitToLast' does not exist on type 'QueryOrderByConstraint'.
90 | const dummy = useRef() as React.MutableRefObject
91 | const messagesRef = collection(db, 'messages')

92 | const messagesQuery = query(messagesRef, orderBy('createdAt').limitToLast(25) )
| ^^^^^^^^^^^
93 |
94 | const [messages, loading, error] = useCollection(messagesQuery, {
95 | snapshotListenOptions: { includeMetadataChanges: true },

@ralfs66
Copy link

ralfs66 commented Apr 30, 2023

import {
addDoc,
collection,
getFirestore,
orderBy,
query,
limitToLast,
Timestamp,
} from 'firebase/firestore'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants